//app.js
App({
  data:{
    url:"https://www.bzt-better.com",
    islogin:false,
    quanbushijian:5000
  },
      onLaunch: function () {
        //调用API从本地缓存中获取数据
        var logs = wx.getStorageSync('logs') || []
        logs.unshift(Date.now())
        wx.setStorageSync('logs', logs);
        var isFir = wx.getStorageSync('isFirst');
        if (isFir) {
          wx.navigateTo({
            url: "../pages/indexfirst/indexfirst"
          });
        } else {
          wx.navigateTo({
          url: "../pages/index/index"
          });
        }
      },


  getUserInfo: function (cb) {
    var that = this
    if (this.globalData.userInfo) {
      typeof cb == "function" && cb(this.globalData.userInfo)
    } else {
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              wx.setStorageSync('isFirst', res.userInfo);
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },
  globalData: {
    userInfo: null
  }
})